package com.dk.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dk.mapper.CarMapper;
import com.dk.mapper.TypeMapper;
import com.dk.pojo.Car;
import com.dk.pojo.Type;
import com.dk.service.Carservice;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
@Service
@org.springframework.stereotype.Service
public class CarserviceImpl implements Carservice {
    @Autowired
    private CarMapper carMapper;
    @Autowired
    private TypeMapper typeMapper;
    @Override
    public List<Type> getInfo() {
        List<Type> list = typeMapper.selectByExample(null);
        return list;
    }

    @Override
    public List<Car> getnfo() {
        List<Car> list = carMapper.getInfo();

        return list;
    }

    @Override
    public boolean addInfo(Car car) {
        if (carMapper.insertSelective(car)>0){
            return true;
        }
        return false;
    }

    @Override
    public boolean deleteInfo(Integer cid) {
        if (carMapper.deleteByPrimaryKey(cid) > 0){
            return true;
        }
        return false;
    }

    @Override
    public boolean deleteAll(Integer[] cid) {
        carMapper.deleteAll(cid);
        return true;
    }

    @Override
    public Car getnfoByCid(Integer id) {
        Car c  = carMapper.selectByPrimaryKey(id);
        return c;
    }

    @Override
    public boolean updateInfo(Car car) {
        if (carMapper.updateByPrimaryKeySelective(car)>0){
            return true;
        }
        return false;
    }
}
